<template>
  <div class="newsDetails_container">
    <div class="details_title">
      <h1>{{title}}</h1>
      <!-- <p class="source">{{source}}</p> -->
      <p class="time">{{time}}</p>
    </div>
    <el-row :gutter="10">
      <el-col :xs="16" :sm="16" :md="16" :lg="16" :xl="16">
        <div class="left_item">
          <div class="details" v-html="content">{{content}}> </div>
        </div>
      </el-col>

      <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
        <div class="right_item ">
          <div class="clearfix right_list">
            <div class="name">
              <p>
                最新文章
              </p>
              <i></i>

            </div>
            <ul>
              <li class="text-1" @click="details(item.id)" v-for="(item,index) in list.slice(0, 8)" :key="index">{{item.title}}</li>
            </ul>

          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<style scoped>
/* .details >>> p {
  color: #ff0 !important;
} */
</style>
<script>
import path from '@/network'
export default {
  name: 'App',
  data () {
    return {
      secondId: this.$route.query.secondId,
      firstId: this.$route.query.firstId,
      type: this.$route.query.type,
      count: 0,
      title: '',
      time: '',
      source: '',
      content: '',
      total: 0,
      pagesize: 50,
      currentPage: 1,
      list: [],
    };
  },

  mounted () {
    if (this.type == 1) {
      this.getLiveDetails(this.$route.query.secondId);
      this.getSecondType(this.$route.query.firstId)
    } else {
      this.getRuleDetails(this.$route.query.secondId);
      this.getSecondType(this.$route.query.firstId)

    }

  },
  methods: {
    getSecondType (id) {
      path.getSecondType(
        id
      ).then(res => {
        if (res.success === 0) {
          this.tabsData = res.rows;
          if (res.rows) {
            if (this.type == 1) {

              this.getLiveList(res.rows[0].id);
            } else {
              this.getRulesList(res.rows[0].id);
            }
          }

        }

      })
    },

    //获取list
    getLiveDetails (id) {
      path.getLiveDetails(
        id
      ).then(res => {
        if (res.success === 0) {
          this.title = res.rows.title
          this.time = res.rows.createTime
          this.source = res.rows.profiles
          this.content = res.rows.content
        }

      })
    },

    //获取list
    getRuleDetails (id) {
      path.getRuleDetails(
        id
      ).then(res => {
        if (res.success === 0) {
          this.title = res.rows.title
          this.time = res.rows.createTime
          this.source = res.rows.profiles
          this.content = res.rows.content
        }

      })
    },



    //获取list
    getRulesList (id) {
      path.getRulesList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.list = res.rows;
        }

      })
    },


    //获取list
    getLiveList (id) {
      path.getLiveList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.list = res.rows;
        }

      })
    },

    details: function (id) {
      if (this.type == 1) {
        this.getLiveDetails(id)
      } else {
        this.getRuleDetails(id)

      }

    },


  }
}
</script>